﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CollegeWebsite.Models;

namespace CollegeWebsite.Controllers
{
    public class FeedbackController : Controller
    {
        private readonly CollegeDataContext _dataContext = new CollegeDataContext();
        //
        // GET: /Feedback/Create

        public ActionResult Create()
        {
            FeedBack feedBack = new FeedBack();
            
            return View(feedBack);
        } 

        //
        // POST: /Feedback/Create

        [HttpPost]
        public ActionResult Create(FeedBack feedBack)
        {
            try
            {
                feedBack.FeedBackStatus = true;
                feedBack.FeedBackDate = DateTime.Now;
                // TODO: Add insert logic here
                _dataContext.FeedBacks.InsertOnSubmit(feedBack);
                _dataContext.SubmitChanges();


                return View("ThankYou");
                //return RedirectToAction("Index");
            }
            catch(Exception EXCP)
            {
                ViewData["ErrorInfo"] = EXCP.ToString();
                return View("Error");
            }
        }        
    }
}
